package com.windfone.service.impl;

import java.util.List;

import com.windfone.common.FileTool;
import com.windfone.dao.GiftDao;
import com.windfone.model.Gift;
import com.windfone.model.GiftUser;
import com.windfone.model.Message;
import com.windfone.service.GiftService;

public class GiftServiceImpl implements GiftService {
	private GiftDao giftDao;
	public void setGiftDao(GiftDao giftDao) {
		this.giftDao = giftDao;
	}

	public int addGift(Gift bean) {
		return giftDao.addGift(bean);
	}

	public int delGift(Gift bean) {
//		Gift b2 = giftDao.getGift(bean);
		String suffix = bean.getImagepath();
		FileTool.dealPic(suffix );
		
		suffix = bean.getImagepath2();
		FileTool.dealPic(suffix );

		suffix = bean.getImagepath3();
		FileTool.dealPic(suffix );

		suffix = bean.getImagepath4();
		FileTool.dealPic(suffix );
		
		return giftDao.delGift(bean);
	}

	public int updateGift(Gift bean) {
		return giftDao.updateGift(bean);
	}

	public Gift getGift(Gift bean) {
		return giftDao.getGift(bean);
	}

	public int countTotal() {
		return giftDao.countTotal();
	}

	public int getAllRecorderNumber(String whereCondition) {
		return giftDao.getAllRecorderNumber( whereCondition );
	}

	public List<Gift> getAllGift(int beginRecord, String whereCondition) {
		return giftDao.getAllGift( beginRecord ,whereCondition);
	}

	public int addMessage(Message bean) {
		return giftDao.addMessage(bean);
	}

	public int delMessage(Message bean) {
		return giftDao.delMessage(bean);
	}

	public int updateMessage(Message bean) {
		return giftDao.updateMessage(bean);
	}

	public Message getMessage(Message bean) {
		return giftDao.getMessage(bean);
	}

	public int getAllMessageRecorderNumber(String whereCondition) {
		return giftDao.getAllMessageRecorderNumber(whereCondition);
	}

	public List<Message> getAllMessage(int beginRecord, String whereCondition) {
		return giftDao.getAllMessage(beginRecord, whereCondition);
	}

	public int addUserGift(int giftId, int userId) {
		return giftDao.addUserGift(giftId, userId);
	}

	public List<GiftUser> getAllUserAskGift(int beginRecord, String whereCondition) {
		return giftDao.getAllUserAskGift(beginRecord,whereCondition);
	}

	public int getAllUserAskGiftRecorderNumber(String whereCondition) {
		return giftDao.getAllUserAskGiftRecorderNumber(whereCondition);
	}

	public int updateUserAskGift(GiftUser bean) {
		return giftDao.updateUserAskGift(bean);
	}

	public int deleteUserAskGift(GiftUser bean) {
		return giftDao.deleteUserAskGift(bean);
	}

}
